package com.ymatou.iapi.captcha.service;

import java.io.IOException;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取验证码（字符串）接口Call
*FreeMaker Template自动生成代码
*/
public class GetCodeCall extends YmatouBaseCall{
	private static String opurl ="GetValidateCode/GetCode";
	private String file = "";
	public GetCodeCall() {
		super(EnvSetup.getSystemUrl("captcha_iapi"),opurl,"GET","PARAM");
	}
	/**
	 * 添加默认header信息
	 */
	@Override
	public void addDefHeader() {
//		super.addDefHeader();
//		client.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8;text/html");
	}

	/* (non-Javadoc)
	 * @see com.ymt.base.BaseCall#callService()
	 */
	@Override
	public void callService() {
		addDefHeader();
		if (beanFormat.equals("PARAM")) {
			entityString = FormatUtil.beanToHttpString(basebean);
		} else if (beanFormat.equals("JSON")) {
			entityString = FormatUtil.beanToJSONString(basebean);
		}
		client.setEntity(entityString);
		try {
			file = client.sendRequestAndWriteResponseToFile();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 获取返回资源的文件路径
	 * 
	 * @return 文件路径
	 */
	public String getFile() {
		return file;
	}
	
	
}